﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using NetCoreCMS.Common;
using NetCoreCMS.IServices;
using NetCoreCMS.Models;
namespace NetCoreCMS.Web.Areas.Admin.Controllers.Dialog
{
    public class Dialog_PrintController : ManageController
    {
        private const string WEB_VIEW = "~/Areas/Admin/Views/Dialog/dialog_print.cshtml";
        private string order_no = string.Empty;
        protected Orders model = new Orders();
        protected Manager adminModel = new Manager();
        public IOrdersService _orders { get; set; }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            if (filterContext.Result != null)
                return;
            order_no = HttpContext.Request.Query["order_no"].FirstOrDefault();
            if (order_no == "")
            {
                JscriptMsg("传输参数不正确！", "back");
                return;
            }
            if (!_orders.Exists(order_no))
            {
                JscriptMsg("订单不存在或已被删除！", "back");
                return;
            }
            ShowInfo(order_no);
        }
        //
        // GET: /admin/Dialog_Print/

        public ActionResult Index()
        {
            return View(WEB_VIEW);
        }

        #region 赋值操作=================================
        private void ShowInfo(string _order_no)
        {
            model = _orders.GetModel(_order_no);
            adminModel = GetAdminInfo();
            ViewData["adminModel"] = adminModel;
            ViewData["model"] = model;
        }
        #endregion
    }
}
